<div class="store-dropdown" id="store-menu">
  <%= dropdown do %>
    <%= dropdown_toggle class: 'store-dropdown-button dropdown-toggle' do %>
      <%= store_admin_icon(current_store, height: 32, width: 32) %>
      <span class="store-name d-none d-lg-block">
        <%= truncate(current_store.name, length: 10) %>
      </span>
    <% end %>
    <%= dropdown_menu class: 'ml-2' do %>
      <%= link_to current_store.formatted_url_or_custom_domain, class: 'dropdown-item', target: '_blank' do %>
        <%= icon 'eye' %>
        <%= Spree.t(:view_store) %>
      <% end %>
      <%= link_to spree.edit_admin_theme_path(current_store.default_theme), class: 'dropdown-item', data: { turbo_prefetch: false } do %>
        <%= icon 'tools' %>
        <%= Spree.t('admin.edit_theme') %>
      <% end if current_store.default_theme && can?(:manage, Spree::Theme) %>

      <% if available_stores.count > 1 %>
        <div class="dropdown-divider"></div>
        <h6 class="dropdown-header">
          <%= Spree.t(:switch_store) %>
        </h6>
        <div class="store-chooser">
          <% available_stores.each do |store| %>
            <% if store.id == current_store.id %>
              <div class="store-chooser-item active">
                <%= store_admin_icon(store, height: 32, width: 32) %>
                <span class="d-flex flex-column mr-2">
                  <%= store.name %>
                  <small class="text-muted">
                    <%= store.url_or_custom_domain %>
                  </small>
                </span>
                <%= icon('check', class: 'ml-auto') %>
              </div>
            <% else %>
              <%= link_to spree.admin_dashboard_url(host: store.url), class: 'store-chooser-item' do %>
                <%= store_admin_icon(store, height: 32, width: 32) %>
                <span class="d-flex flex-column">
                  <%= store.name %>
                  <small class="text-muted">
                    <%= store.url_or_custom_domain %>
                  </small>
                </span>
              <% end %>
            <% end %>
          <% end %>
        </div>
      <% end %>
    <% end %>
  <% end %>

  <%= render 'spree/admin/shared/new_item_dropdown' %>
</div>
